package com.fs.web.yz.service.impl;

import com.fs.common.pojo.User;
import com.fs.common.yzMapper.CheckNoteMapper;
import com.fs.web.base.utils.ApplicationUtils;
import com.fs.web.yz.service.ICheckNoteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class CheckNoteServiceImplWeb implements ICheckNoteService {

    @Autowired
    CheckNoteMapper checkNoteMapper;

    /**
     * 根据日期获取问卷数量
     * @return
     */
    @Override
    public List<Map> getCountForDate(List<String> dayList) {
        User user = ApplicationUtils.getUser().getUser();
        List<Map> list = new ArrayList<>();
        for (int i = 0; i < dayList.size()-1;i++){
            String day = dayList.get(i);
            String userId = null;
            if (!user.isSysAdm()){
                userId = user.getId();
            }
            int checkNoteCount = checkNoteMapper.findCheckNoteForDate(day + " 00:00:00", day + " 23:59:59",userId);
            Map<String, Object> map = new HashMap<>();
            map.put("toDay",day);
            map.put("checkNoteCount",checkNoteCount);
            list.add(map);
        }
        return list;
    }
}
